import { App } from 'vue'
import { defineAsyncComponent, AsyncComponentLoader } from 'vue'

const compo = import.meta.glob('./**/*.vue')

export default {
  install(app: App) {
    for (const [key, value] of Object.entries(compo)) {
      const name = key.slice(key.lastIndexOf('/') + 1, key.lastIndexOf('.'))
      app.component(name, defineAsyncComponent(value as AsyncComponentLoader))
    }
  },
}
